package com.javase.SY04;

public class Triangle {
    int edge1,edge2,edge3;

    public Triangle(int edge1, int edge2, int edge3) {
        this.edge1 = edge1;
        this.edge2 = edge2;
        this.edge3 = edge3;
    }

    public boolean judge(){
        if (edge1+edge2>edge3&&edge1+edge3>edge2&&edge2+edge3>edge1){
            return true;
        }else {
            return false;
        }
    }

    public double area() {
        boolean flag = judge();
        double area,perimeter;
        perimeter = (edge1 + edge2 + edge3) / 2;
        if (flag){
            area = Math.sqrt(perimeter*(perimeter-edge1)*(perimeter-edge2)*(perimeter-edge3));
        }else {
            area = 0;
            System.out.println("三边无法构成三角形");
        }
        return area;
    }
    public void setEdge1(int edge1) {
        this.edge1 = edge1;
    }

    public void setEdge2(int edge2) {
        this.edge2 = edge2;
    }

    public void setEdge3(int edge3) {
        this.edge3 = edge3;
    }



    public static class Test{
        public static void main(String[] args) {
            Triangle t = new Triangle(3, 4, 5);
            double area = t.area();
            System.out.println("面积：" + area);
        }
    }
}
